package com.situ.dao;


import java.util.*;


import java.util.List;
import java.util.Map;



import com.situ.common.Assist;
import com.situ.entity.FuHeFaPiao;
import com.situ.entity.FuHeFaPiaomingxi;
import com.situ.entity.IvIninvoice;
import com.situ.entity.IvInvoice;
import com.situ.entity.SyEmp;
import org.apache.ibatis.annotations.*;

/**
 * IvInvoice的Dao接口
 *
 * @author
 */
@Mapper
public interface IvInvoiceDao {
    @Select("select A.InvoiceType,B.StartNo,B.EndNo,D.Counts,B.Counts s,A.Used,A.Invalid,A.Archived,D.InDate,C.EmpNmae\n" +
            "from IV_Invoice A join IV_InInvoice D on A.InID=D.ID\n" +
            "\t\t\tjoin IV_OutInvoice B on A.OutID=B.ID\n" +
            "\t\t\tjoin SY_Emp C on D.InEmpID=C.id")

	/**
	 * 获得IvInvoice数据的总行数,可以通过辅助工具Assist进行条件查询,如果没有条件则传入null
	 * 
	 * @param assist
	 * @return
	 */
	long getIvInvoiceRowCount(Assist assist);

	//发票情况汇总报表
	@Select("select a.Used,a.Invalid,b.Counts,b.StartNo,b.EndNo,b.InDate,a.ArchiveDate,c.EmpNmae  from IV_Invoice a inner join IV_InInvoice b on a.InID=b.ID inner join SY_Emp c on a. EmpID=c.id")
	public List<Map> queryhuizong();
	
	//发票情况汇总的高级查询
	public List<Map> queryhuizonggaoji(@Param("EmpID")int EmpID,@Param("InvoiceType")int InvoiceType);
	//汇总报表
	public List<Map> findhuizonggaoji(FuHeFaPiao fuhe);
	//汇总明细
	public List<Map> findmingxigaoji(FuHeFaPiao fuhe);

	//查询总金额
	@Select("select sum(PayMoney) as'zmoney' from .PY_Pay")
	public List<Map> queryzmoney();

	//查询所有员工做下拉框
	@Select("select * from SY_Emp")
	public List<SyEmp> queryxialaemp();

	//发票使用情况明细表
	@Select("select a.InvoiceType,a.InvoiceNo,b.PayNo,c.UserName,b.PayMoney,b.PayDate,d.EmpNmae from IV_Invoice a inner join PY_Pay b on a.InvoiceNo=b.Invoice inner join BE_OrderLite c on b.UserNo=c.UserNo inner join SY_Emp d on c.EmpID=d.ID")
	public List<Map> querymingxi();

	//查询总张数
	@Select("select sum(Counts) as 'counts' from IV_InInvoice")
	public int queryzshu();
	//查询已用的总张数
	@Select("select sum(Used) as 'used' from IV_Invoice")
	public int queryusezshu();
	//查询作废的总张数
	@Select("select sum(Invalid) as 'zuofei' from IV_Invoice")
	public int queryzuofeizshu();
	//查询总金额
	@Select("select sum(PayMoney) as 'zmoney' from .PY_Pay")
	public int queryzjmoney();
	//销账汇总报表
	//查询一个总的数据
	@Select("select sum(b.PayMoney) jfmoney,sum(b.UseMoney) yiyongmoney,sum(c.Amount) xzcount,sum(a.BalanceMoney) xzmoney from PY_Balance a inner join PY_Pay b on a.UserNo=b.UserNo inner join PY_BillDetail c on a.BillNo=c.BillNo")
	public List<Map> queryzong();
	//查询各种分类用水量和销账金额
	@Select("select sum(Amount) fenleiyongshui,sum(BalanceMoney) fleixiaoz from PY_Balance a inner join RD_ReadTypes b on a.UserNo=b.UserNo group by b.WaterTypeCode ")
	public List<Map> queryyongshuixiaoz();
	//销账明细报表
	@Select("\r\n" + 
			"select b.PayNo,a.InvoiceNo,a.InvoiceType,a.ArchiveDate,b.PayMoney,b.UseMoney,c.EmpNmae,d.Amount,e.BalanceMoney from IV_Invoice a inner join PY_Pay b on a.InvoiceNo=b.Invoice inner join SY_Emp c on b.EmpID=c.id inner join RD_ReadTypes d on b.UserNo=d.UserNo inner join PY_Balance e on d.UserNo=e.UserNo")
	public List<Map> queryxiaozhanmingxi();
	//销账明细报表高级查询
	public List<Map> Findxiaozhanmingxigaoji(FuHeFaPiaomingxi fuhe);
	/**
	 * 获得IvInvoice数据集合,可以通过辅助工具Assist进行条件查询,如果没有条件则传入null
	 * 
	 * @param assist
	 * @return
	 */

	
	/**
	 * 通过辅助工具Assist的条件更新IvInvoice中属性不为null的数据
	 * 
	 * @param value
	 * @param assist
	 * @return
	 */
	int updateNotNullIvInvoice(@Param("enti") IvInvoice value, @Param("assist") Assist assist);

    @Select("select A.InvoiceType,B.StartNo,B.EndNo,D.Counts,B.Counts s,A.Used,A.Invalid,A.Archived,D.InDate,C.EmpNmae\n" +
            "from IV_Invoice A join IV_InInvoice D on A.InID=D.ID\n" +
            "\t\t\tjoin IV_OutInvoice B on A.OutID=B.ID\n" +
            "\t\t\tjoin SY_Emp C on D.InEmpID=C.id")
    List<Map> queryAll();

    


    /**
     * 获得IvInvoice数据集合,可以通过辅助工具Assist进行条件查询,如果没有条件则传入null
     *
     * @param assist
     * @return
     */
    List<IvInvoice> selectIvInvoice(Assist assist);

    /**
     * 通过IvInvoice的id获得IvInvoice对象
     *
     * @param id
     * @return
     */
    IvInvoice selectIvInvoiceById(String id);

    /**
     * 获得一个IvInvoice对象,以参数IvInvoice对象中不为空的属性作为条件进行查询,返回符合条件的第一条
     *
     * @param obj
     * @return
     */
    IvInvoice selectIvInvoiceObjSingle(IvInvoice obj);

    /**
     * 获得一个IvInvoice对象,以参数IvInvoice对象中不为空的属性作为条件进行查询
     *
     * @param obj
     * @return
     */
    List<IvInvoice> selectIvInvoiceByObj(IvInvoice obj);

    /**
     * 插入IvInvoice到数据库,包括null值
     *
     * @param value
     * @return
     */
    int insertIvInvoice(IvInvoice value);

    /**
     * 插入IvInvoice中属性值不为null的数据到数据库
     *
     * @param value
     * @return
     */
    int insertNotNullIvInvoice(IvInvoice value);

    /**
     * 批量插入IvInvoice到数据库,包括null值
     *
     * @param value
     * @return
     */
    int insertIvInvoiceByBatch(List<IvInvoice> value);

    /**
     * 通过IvInvoice的id删除IvInvoice
     *
     * @param id
     * @return
     */
    int deleteIvInvoiceById(String id);

    /**
     * 通过辅助工具Assist的条件删除IvInvoice
     *
     * @param assist
     * @return
     */
    int deleteIvInvoiceByAssist(Assist assist);

    /**
     * 通过IvInvoice的id更新IvInvoice中的数据,包括null值
     *
     * @param enti
     * @return
     */
    int updateIvInvoiceById(IvInvoice enti);

    /**
     * 通过IvInvoice的id更新IvInvoice中属性不为null的数据
     *
     * @param enti
     * @return
     */
    int updateNotNullIvInvoiceById(IvInvoice enti);

    /**
     * 通过辅助工具Assist的条件更新IvInvoice中的数据,包括null值
     *
     * @param value
     * @param assist
     * @return
     */
    int updateIvInvoice(@Param("enti") IvInvoice value, @Param("assist") Assist assist);


    /**
     * 通过辅助工具Assist的条件更新IvInvoice中属性不为null的数据
     *
     * @param value
     * @param assist
     * @return
     */

}